package com.neutech.jdbc.test;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

public class JDBCTest2 {
    public static void main(String[] args) {
        //添加语句
        try {
            //1加载驱动
            Class.forName("com.mysql.jdbc.Driver");
            //2连接驱动
            Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/s_t","root","123");
            //s_t是数据库的库名
            //3创建sql语句
            String sql = "insert into course  values('c020','张智淇',1,2)";
            //sc是表名
            //4创建statement接口
            Statement stmt = conn.createStatement();
            //5.executeUpdate用来执行DML操作，增删改操作
            //executeQuery用来执行DQL操作，查询
             int rows = stmt.executeUpdate(sql);
            System.out.println("更新了："+ rows + "行记录");
            //6.关闭
            stmt.close();
            conn.close();


        }catch (Exception e){
            e.printStackTrace();
        }








    }
}
